﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using SharedGenomics.Workbench.Models;

namespace SharedGenomics.Workbench.Tests.Models
{
    [TestClass]
    public class CoverflowUriResolverTests
    {
        private CoverflowUriResolver resolver;

        [TestInitialize]
        public void Setup()
        {
            Uri baseUri = new Uri("http://www.example.com/silverlightpage.aspx");
            this.resolver = new CoverflowUriResolver(baseUri);
        }

        [TestMethod]
        public void ShouldCreateUriForAllAnnotations()
        {
            Guid id = Guid.NewGuid();

            Uri resolvedUri = this.resolver.ResolveUri(id, SessionAnnotationDisplayImportance.All);
            Uri expectedUri = new Uri(String.Format("http://www.example.com/silverlightpage.aspx?id={0}&show=all", id));
            Assert.AreEqual(expectedUri, resolvedUri);
        }

        [TestMethod]
        public void ShouldCreateUriForHighlightedAnnotations()
        {
            Guid id = Guid.NewGuid();

            Uri resolvedUri = resolver.ResolveUri(id, SessionAnnotationDisplayImportance.Highlight);
            Uri expectedUri = new Uri(String.Format("http://www.example.com/silverlightpage.aspx?id={0}&show=highlight", id));
            Assert.AreEqual(expectedUri, resolvedUri);
        }

        [TestMethod]
        public void ShouldCreateUriForImportantAnnotations()
        {
            Guid id = Guid.NewGuid();

            Uri resolvedUri = resolver.ResolveUri(id, SessionAnnotationDisplayImportance.Important);
            Uri expectedUri = new Uri(String.Format("http://www.example.com/silverlightpage.aspx?id={0}&show=important", id));
            Assert.AreEqual(expectedUri, resolvedUri);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructorShouldThrowIfBaseUriNull()
        {
            CoverflowUriResolver resolver = new CoverflowUriResolver(null);
        }
    }
}
